//
// Created by mio on 25-5-13.
//

#ifndef AACENCODER_H
#define AACENCODER_H

#include "AV_Common.h"

// TODO: 重构 AudioCapture -> AACEncodr + WSACaputre / AudioCapture( AACEncoder ) -> WSACapture

class AACEncoder;

class AudioEncoder
{
public:
    AudioEncoder();
    AudioEncoder(const AudioEncoder&) = delete;
    AudioEncoder& operator=(const AudioEncoder&) = delete;
    ~AudioEncoder();
public:
    bool Open(int samplerate, int channels, int format, int bitrate_kbps);
    void Close();
    int  GetFrames();
    int  GetSpecificConfig(uint8_t* buf,int max_buf_size);
    AVPacketPtr Encode(const uint8_t* pcm,int samples);

    inline int  GetChannel(){return channel_;}
    inline int  GetSamplerate(){return samplerate_;}
private:
    int channel_ = 0;
    int bitrate_ = 0;
    int samplerate_ = 0;
    AVSampleFormat format_ = AV_SAMPLE_FMT_NONE;
    std::unique_ptr<AACEncoder> AAC_encoder_;
};


#endif //AACENCODER_H